﻿namespace _3_FactoryMethod;

public class Program
{
    public static void Main(string[] args)
    {
        var shapes = new List<Shape>();
        for (var i = 0; i < 10; i++)
        {
            var shape=ShapeFactory.CreateRandomShape();
            shapes.Add(shape);
        }

        double totalArea = 0;
        foreach (var shape in shapes)
        {
            Console.WriteLine(shape.ToString());
            if (shape.IsValid())
            {
                totalArea += shape.Area();
            }
            else
            {
                Console.WriteLine("Invalid Shape");
            }
        }
        Console.WriteLine("总面积为："+totalArea.ToString("F2"));
    }
}